from asyncio import FastChildWatcher
from code import interact
import os
import time
import numpy as np
from isaacgym import gymutil
from isaacgym import gymapi
#from isaacgym import gymtorch
from math import sqrt
import math
from sympy import false
import torch
import cv2

from draw import *

from pcgworker.PCGWorker import *

from wfc_vecenv_stable_baselines import *

from stable_baselines3 import PPO
from stable_baselines3.common.callbacks import BaseCallback
from stable_baselines3.common.results_plotter import load_results, ts2xy
from stable_baselines3.common.monitor import Monitor
from stable_baselines3.common import results_plotter
from stable_baselines3.common.results_plotter import load_results, ts2xy, plot_results
from stable_baselines3.common.noise import NormalActionNoise
from stable_baselines3.common.callbacks import BaseCallback

LOGDIR = "./training_logs"
timesteps = 200000

m_env = PCGVecEnvStableBaselines(seed_pth = "./trial1/gen_25_dec_3.json", headless_ = False)
observation = m_env.reset()

model = PPO.load("./model_25.zip", env=m_env)

model_ = PPO('CnnPolicy', env=m_env, batch_size = 1024)
model_.set_parameters(model.get_parameters())

while True:

    action, _states = model_.predict(observation, deterministic=False)

    observation, reward, done, info = m_env.step(action)

    m_env.render()

    # time.sleep(0.033)

